import request from '@/utils/request'

// 获取首页数据
export const getHomeGoods = (): Promise<General.result<HomeData.HomeGoods>> => request({
  url: '/home/getData',
  method: 'get',
})

// 获取用户列表数据
export const getUserListData = (params: General.pageParams): Promise<General.page<UserData.User>> => request({
  url: '/user/getUserList',
  method: 'get',
  params
})

// 添加用户数据
export const addUserData = (data: UserData.User): Promise<General.result<{ message: string }>> => request({
  url: '/user/addUser',
  method: 'post',
  data
})

// 更新用户数据
export const updateUserData = (data: UserData.User): Promise<General.result<{ message: string }>> => request({
  url: '/user/updateUser',
  method: 'post',
  data
})

// 删除用户数据
export const deleteUserData = (id: string): Promise<General.result<{ message: string }>> => request({
  url: '/user/deleteUser',
  method: 'post',
  data: { id }
})

export const userLogin = (data: { userName: string, password: string }) => request({
  url: '/user/login',
  method: 'post',
  data
})